# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer:
pkgname=ocaml-lwt_log
_pkgname=lwt_log
pkgver=1.1.0
pkgrel=1
pkgdesc="Lwt-friendly logger"
url="https://github.com/aantron/lwt_log"
arch="all !x86 !armhf !armv7 !s390x !mips !mips64"  # limited by ocaml aport
license="LGPL-2.1-or-later-WITH-linking-exception BSD-3-Clause"
depends="ocaml-runtime ocaml-lwt>=4.0.0"
makedepends="dune ocaml ocaml-findlib ocaml-lwt-dev>=4.0.0 opam"
options="!check"  # no tests provided
subpackages="$pkgname-dev"
source="https://github.com/aantron/$_pkgname/archive/$pkgver/$_pkgname-$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver"

build() {
	cd "$builddir"
	jbuilder build @install
}

package() {
	cd "$builddir"

	mkdir -p "$pkgdir"/usr/lib/ocaml
	jbuilder install \
		--destdir="$pkgdir"/usr \
		--libdir="$pkgdir"/usr/lib/ocaml

	# There's just a readme and changelog.
	rm -Rf "$pkgdir"/usr/doc

	# Remove annotation files and sources.
	cd "$pkgdir"/usr/lib/ocaml/$_pkgname
	rm -f *.cmt* */*.cmt* *.ml */*.ml
}

dev() {
	default_dev
	depends="$pkgname=$pkgver-r$pkgrel"

	cd "$pkgdir"

	local path; for path in $(find usr/lib/ocaml/$_pkgname \
		-name '*.cmx' -o \
		-name '*.cmxa' -o \
		-name '*.mli')
	do
		mkdir -p "${path%/*}"
		mv "$path" "$subpkgdir"/${path%/*}/
	done
}

sha512sums="fa0ce2928912b55ecbddc14ecd6f6d5db399f7cd6cba5f38d61db4c89ab7345d3e42f8f1292d9a5be973e16fd43d8381d6c269ae47f3692bb64ff567a7039451  lwt_log-1.1.0.tar.gz"
